home *** CD-ROM | disk | FTP | other *** search
- class classes.enemy.BugD
- {
- var x;
- var y;
- var moveScript;
- var id;
- var clip;
- var colorR;
- var trans;
- var colorTrans;
- var f2;
- var scc;
- var axis;
- var dir;
- var switchDir;
- var sfc;
- var sfMax;
- var xDest;
- var yDest;
- var oldDir;
- var firing;
- var fc;
- var xMov = 0;
- var yMov = 0;
- var xMovT = 0;
- var yMovT = 0;
- var speedOrig = 9;
- var speed = 9;
- var xDestMet = false;
- var yDestMet = false;
- var c = 0;
- var life = 6;
- var nudging = false;
- var nc = 0;
- var xA = 0;
- var yA = 0;
- var power = 25;
- var Name = "bugD";
- function BugD(px, py, pmoveScript, pid)
- {
- this.x = px;
- this.y = py;
- this.moveScript = pmoveScript.slice();
- this.id = pid;
- _root.d = _root.d + 1;
- this.clip = _root.attachMovie("bugA","bugD" + this.id + "Clip",_root.d + 50000);
- this.clip._x = this.x;
- this.clip._y = this.y;
- this.speed *= _root.dif.speed;
- this.speedOrig = this.speed;
- this.life *= _root.dif.life;
- this.colorR = -255;
- this.trans = new flash.geom.Transform(this.clip);
- this.colorTrans = new flash.geom.ColorTransform(0,0,0,1,this.colorR,this.colorR,this.colorR,0);
- this.trans.colorTransform = this.colorTrans;
- this.speedVar();
- this.parseMoveScript();
- _root.stats.created = _root.stats.created + 1;
- }
- function bombed(num)
- {
- this.f2 = "death";
- }
- function switchScope()
- {
- this.scc = 0;
- this.getDirString();
- this.f2 = "switchScoping";
- this.c = 5;
- this.speed /= 2;
- this[this.axis + "MovT"] /= 2;
- this.clip.body.flame.gotoAndStop("still");
- _root.audio.playLevel2("bugDSwitch",_root.randRange(8,15));
- }
- function switchScoping()
- {
- this.c = this.c + 1;
- if(this.c == 10)
- {
- this.scc = this.scc + 1;
- this.c = 0;
- if(this.dir == "U" || this.dir == "D")
- {
- _root.d = _root.d + 1;
- _root.attachMovie("sight","sightClip",_root.d);
- _root.sightClip.gotoAndStop("bugDSwitchFire");
- _root.sightClip._x = this.x;
- _root.sightClip._y = this.y;
- if(_root.sightClip.hitTest(_root[_root.char].x,_root[_root.char].y,true))
- {
- this.switchFire("L");
- }
- else
- {
- _root.sightClip._rotation = 180;
- if(_root.sightClip.hitTest(_root[_root.char].x,_root[_root.char].y,true))
- {
- this.switchFire("R");
- }
- }
- removeMovieClip(_root.sightClip);
- }
- else
- {
- _root.d = _root.d + 1;
- _root.attachMovie("sight","sightClip",_root.d);
- _root.sightClip.gotoAndStop("bugDSwitchFire");
- _root.sightClip._x = this.x;
- _root.sightClip._y = this.y;
- _root.sightClip._rotation = 90;
- if(_root.sightClip.hitTest(_root[_root.char].x,_root[_root.char].y,true))
- {
- this.switchFire("U");
- }
- else
- {
- _root.sightClip._rotation = -90;
- if(_root.sightClip.hitTest(_root[_root.char].x,_root[_root.char].y,true))
- {
- this.switchFire("D");
- }
- }
- removeMovieClip(_root.sightClip);
- }
- if(this.scc > _root.randRange(9,12))
- {
- this.clip.body.gotoAndStop("main");
- this.speed = this.speedOrig;
- this[this.axis + "MovT"] *= 2;
- this.clip.body.flame.gotoAndPlay("start");
- this.f2 = "wander";
- }
- }
- }
- function switchFire(tmpDir)
- {
- this.clip.gotoAndStop("fly" + tmpDir);
- this.switchDir = tmpDir;
- this.c = 0;
- this.sfc = 0;
- this.f2 = "switchFiring";
- this.sfMax = _root.randRange(1,2);
- }
- function switchFireBlast()
- {
- this.clip.body.gotoAndPlay("switchFire");
- if(this.switchDir == "L")
- {
- var _loc3_ = this.x - 24;
- var _loc4_ = this.dir != "U" ? this.y + 21 : this.y + 3;
- }
- else if(this.switchDir == "R")
- {
- _loc3_ = this.x + 9;
- _loc4_ = this.dir != "U" ? this.y + 21 : this.y + 3;
- }
- else if(this.switchDir == "U")
- {
- _loc3_ = this.dir != "L" ? this.x + 21 : this.x + 3;
- _loc4_ = this.y - 36;
- }
- else
- {
- _loc3_ = this.dir != "L" ? this.x + 21 : this.x + 3;
- _loc4_ = this.y + 15;
- }
- _root.enemyShotID = _root.enemyShotID + 1;
- _root["bugASwitchBlast" + _root.enemyShotID] = new classes.shots.BugASwitchBlast(_loc3_,_loc4_,this.switchDir,_root.enemyShotID,true);
- _root.addEnemyShot("bugASwitchBlast" + _root.enemyShotID);
- _root.audio.playLevel3("bugASwitchBlast" + (random(2) + 1),_root.randRange(15,25));
- }
- function switchFiring()
- {
- this.c = this.c + 1;
- if(this.c == 10)
- {
- this.clip.body.gotoAndPlay("switch");
- }
- if(this.c == 17)
- {
- this.switchFireBlast();
- }
- if(this.c == 24)
- {
- this.switchFireBlast();
- this.c = 18;
- this.sfc = this.sfc + 1;
- if(this.sfc == this.sfMax)
- {
- this.clip.body.gotoAndPlay("switchRev");
- this.c = 33;
- }
- }
- if(this.c == 45)
- {
- this.clip.gotoAndStop("fly" + this.dir);
- this.clip.body.gotoAndStop("main");
- this.speed = this.speedOrig;
- this[this.axis + "MovT"] *= 2;
- this.clip.body.flame.gotoAndPlay("start");
- }
- }
- function nudge(pxA, pyA, pscale)
- {
- this.nc = 0;
- this.nudging = true;
- var _loc2_ = pscale / 100;
- this.xA = pxA * _loc2_;
- this.yA = pyA * _loc2_;
- }
- function speedVar()
- {
- if(random(3) == 1)
- {
- this.speed *= _root.randRange2(0.99999,1.00001);
- }
- }
- function parseMoveScript()
- {
- this.dir = this.moveScript[0];
- if(this.dir == "break")
- {
- delete this.moveScript;
- if(random(2) == 1)
- {
- this.f2 = "wander";
- this[this.axis + "MovT"] = 0;
- this.axis = this.axis != "y" ? "y" : "x";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.speedVar();
- this.getDirString();
- }
- else
- {
- this.switchScope();
- }
- }
- else
- {
- this[this.axis + "MovT"] = 0;
- this.f2 = "gotoXYDest";
- this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
- this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
- this.speedVar();
- if(this.dir == "L" || this.dir == "U")
- {
- this[this.axis + "Dest"] = this[this.axis] - this.moveScript[1];
- }
- else
- {
- this[this.axis + "Dest"] = this[this.axis] + this.moveScript[1];
- }
- this.moveScript.splice(0,2);
- }
- }
- function gotoXYDest()
- {
- if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
- {
- if(this.axis == "x")
- {
- this.x = this.xDest;
- }
- else
- {
- this.y = this.yDest;
- }
- this.parseMoveScript();
- }
- }
- function getDirString()
- {
- if(this.xMovT < -1)
- {
- this.dir = "L";
- }
- else if(this.xMovT > 1)
- {
- this.dir = "R";
- }
- else if(this.yMovT > 1)
- {
- this.dir = "D";
- }
- else if(this.yMovT < -1)
- {
- this.dir = "U";
- }
- }
- function evade()
- {
- this[this.axis + "MovT"] = 0;
- this.axis = this.axis != "x" ? "x" : "y";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- this.f2 = "wander";
- }
- function attacking()
- {
- this.xMovT *= 1.03;
- this.yMovT *= 1.03;
- }
- function death()
- {
- _root.stats.destroyed = _root.stats.destroyed + 1;
- _root.stats.score += 2500;
- _root.powerUpB(this.x,this.y,80,"rapidLaser",5);
- _root.createExploD([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(80,130),_root.randRange(75,100)]);
- _root.audio.playLevel4("bugX" + (random(4) + 1),_root.randRange(7,17));
- var _loc3_ = 0;
- var _loc4_ = random(3);
- while(_loc3_ < _loc4_)
- {
- _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"bugA","",false,true]);
- _loc3_ = _loc3_ + 1;
- }
- _root.removeChar("bugD" + this.id);
- this.f2 = "";
- }
- function wander()
- {
- if(random(100) > 98 + _root.dif.wander)
- {
- this[this.axis + "MovT"] = 0;
- this.axis = this.axis != "x" ? "x" : "y";
- this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
- this.getDirString();
- }
- if(random(100) > 98 + _root.dif.wander)
- {
- this.switchScope();
- }
- }
- function death2()
- {
- _root.removeChar("bugD" + this.id);
- this.f2 = "";
- }
- function main()
- {
- this[this.f2]();
- if(this.oldDir != this.dir)
- {
- this.clip.gotoAndStop("fly" + this.dir);
- }
- this.oldDir = this.dir;
- if(random(300) >= 299 + _root.dif.wander)
- {
- _root.d = _root.d + 1;
- _root.attachMovie("feeler","feelerClip",_root.d);
- if(this.dir == "L")
- {
- var _loc9_ = [-310,0,300,50];
- }
- else if(this.dir == "R")
- {
- _loc9_ = [50,0,300,50];
- }
- else if(this.dir == "U")
- {
- _loc9_ = [0,-310,50,300];
- }
- else
- {
- _loc9_ = [0,50,300,50];
- }
- _root.feelerClip._x = this.x + _loc9_[0];
- _root.feelerClip._y = this.y + _loc9_[1];
- _root.feelerClip._width = _loc9_[2];
- _root.feelerClip._height = _loc9_[3];
- var _loc4_ = 0;
- var _loc8_ = _root.chars.length;
- var _loc7_ = false;
- while(_loc4_ < _loc8_)
- {
- var _loc6_ = _root.chars[_loc4_] + "Clip";
- if(_root.feelerClip.hitTest(_root[_loc6_]))
- {
- var _loc3_ = _root.chars[_loc4_];
- if(_root[_loc3_].Name.substr(0,3) != "bro")
- {
- _loc7_ = true;
- }
- }
- _loc4_ = _loc4_ + 1;
- }
- removeMovieClip(_root.feelerClip);
- if(!_loc7_)
- {
- _root.d = _root.d + 1;
- _root.attachMovie("sight","sightClip",_root.d);
- _root.sightClip._x = this.x;
- _root.sightClip._y = this.y;
- if(this.dir == "U")
- {
- _root.sightClip._rotation = 90;
- }
- else if(this.dir == "R")
- {
- _root.sightClip._rotation = 180;
- }
- else if(this.dir == "D")
- {
- _root.sightClip._rotation = -90;
- }
- if(_root.sightClip.hitTest(_root[_root.char].x,_root[_root.char].y,true))
- {
- this.clip.body.charger.gotoAndPlay("fire");
- this.clip.body.eye1.gotoAndPlay("fire");
- this.clip.body.eye2.gotoAndPlay("fire");
- this.clip.body.eye3.gotoAndPlay("fire");
- this.firing = true;
- this.fc = 0;
- }
- removeMovieClip(_root.sightClip);
- }
- }
- if(this.firing)
- {
- this.fc = this.fc + 1;
- if(this.fc == 5)
- {
- if(this.dir == "L")
- {
- var _loc10_ = this.x - 24;
- var _loc13_ = this.y + 12;
- var _loc14_ = this.x - 24;
- var _loc12_ = this.y + 6;
- }
- else if(this.dir == "R")
- {
- _loc10_ = this.x + 9;
- _loc13_ = this.y + 12;
- _loc14_ = this.x + 9;
- _loc12_ = this.y + 6;
- }
- else if(this.dir == "U")
- {
- _loc10_ = this.x + 12;
- _loc13_ = this.y - 24;
- _loc14_ = this.x + 6;
- _loc12_ = this.y - 24;
- }
- else
- {
- _loc10_ = this.x + 12;
- _loc13_ = this.y + 3;
- _loc14_ = this.x + 6;
- _loc12_ = this.y + 3;
- }
- _root.enemyShotID = _root.enemyShotID + 1;
- _root["bugAFireA" + _root.enemyShotID] = new classes.shots.BugAFireA(_loc10_,_loc13_,this.dir,_root.enemyShotID,true);
- _root.addEnemyShot("bugAFireA" + _root.enemyShotID);
- _root.enemyShotID = _root.enemyShotID + 1;
- _root["bugAFireB" + _root.enemyShotID] = new classes.shots.BugAFireB(_loc14_,_loc12_,this.dir,_root.enemyShotID,true);
- _root.addEnemyShot("bugAFireB" + _root.enemyShotID);
- _root.audio.playLevel3("bugAFire",_root.randRange(15,25));
- }
- }
- if(this.nudging)
- {
- this.xA *= 0.5;
- this.yA *= 0.5;
- this.nc = this.nc + 1;
- var _loc11_ = 255 - this.nc * 17;
- this.colorTrans.redOffset = _loc11_;
- this.trans.colorTransform = this.colorTrans;
- if(this.nc == 15)
- {
- this.xA = this.yA = 0;
- this.nudging = false;
- this.colorTrans.redOffset = this.colorR;
- this.trans.colorTransform = this.colorTrans;
- }
- }
- _loc4_ = 0;
- _loc8_ = _root.broShots.length;
- while(_loc4_ < _loc8_)
- {
- _loc6_ = _root.broShots[_loc4_] + "Clip";
- if(this.clip.hitTest(_root[_loc6_]))
- {
- _loc3_ = _root.broShots[_loc4_];
- var _loc5_ = this.life;
- this.life -= _root[_loc3_].power;
- if(this.life < 1)
- {
- this.f2 = "death";
- }
- else
- {
- this.nudge(_root[_loc3_].xMov,_root[_loc3_].yMov,5);
- _root.audio.playLevel4("bugHit" + (random(4) + 1),_root.randRange(7,15));
- }
- _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
- _root[_loc3_].exploX = this.x + this.clip._width / 2;
- _root[_loc3_].exploY = this.y + this.clip._height / 2;
- _root[_loc3_].hit(_loc5_);
- break;
- }
- _loc4_ = _loc4_ + 1;
- }
- if(this.clip.hitTest(_root[_root.char + "Clip"]))
- {
- _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
- this.f2 = "death";
- }
- if(this.x > 1050 || this.x < -50 || this.y < -50 || this.y > 650)
- {
- this.f2 = "death2";
- }
- if(this.xMovT < this.xMov)
- {
- this.xMov -= 1;
- }
- else if(this.xMovT > this.xMov)
- {
- this.xMov += 1;
- }
- else
- {
- this.xMov = this.xMovT;
- }
- if(this.yMovT < this.yMov)
- {
- this.yMov -= 1;
- }
- else if(this.yMovT > this.yMov)
- {
- this.yMov += 1;
- }
- else
- {
- this.yMov = this.yMovT;
- }
- this.x += this.xMov + this.xA;
- this.y += this.yMov + this.yA;
- this.clip._x = this.x;
- this.clip._y = this.y;
- }
- }
-